package com.zerous.simplerts;

import android.graphics.*;
import java.io.*;

public class ZGraphics
{
	Paint paint;
	Canvas canvas;
	Bitmap framebuffer;
	float deltaTime = 0;
	
	public ZGraphics(Bitmap framebuffer)
	{
		this.framebuffer = framebuffer;
		canvas = new Canvas(framebuffer);
		paint = new Paint();
	}
	
	public Sprite createSprite(String fileName)
	{
		Sprite sprite = null;
		try{
			InputStream is = Zef.file.readAssets(fileName);
			sprite = new Sprite(BitmapFactory.decodeStream(is));
		} catch(IOException e) {
			e.printStackTrace();
		}
		return sprite;
	}
	
	public void update(float deltaTime)
	{
		this.deltaTime = deltaTime;
	}
	
	public float getDeltaTime()
	{
		return deltaTime;
	}
	
	public void setTextSize(float size)
	{
		paint.setTextSize(size);
	}
	
	public void clear(int color)
	{
		canvas.drawColor(color);
	}
	
	public void drawSprite(Sprite s, float x, float y)
	{
		canvas.drawBitmap(s.src, x, y, null);
	}
	
	public void drawText(String text, int x, int y)
	{
		canvas.drawText(text, x, y, paint);
	}
	
	public void drawText(float num, int x, int y)
	{
		canvas.drawText(num + "", x, y, paint);
	}
}
